<?php
//this needs some testing
  function tep_validate_password($plain, $encrypted) {
    if (tep_not_null($plain) && tep_not_null($encrypted)) {

      if (md5($plain) == $encrypted) { return true; }
      
      //jnew::
      list($hash, $salt) = explode(':', $encrypted);
      $cryptpass = md5($plain.$salt);
      //$ctest = md5($plains.$salt);
      if ($hash == $cryptpass) { return true; }
      
      //die($hash . '-' . $salt . '<br>' . $encrypted . '<br>' . $cryptpass . "<br>$plain <br> $ctest");
    }
    return false;
  }

////
// This function makes a new password from a plaintext password.
  function tep_encrypt_password($plain) {
  if(!class_exists('JUserHelper')){
            $salt = mosMakePassword(16);
						$crypt = md5($plain.$salt);
						$password = $crypt.':'.$salt;
						}else{
						$salt  = JUserHelper::genRandomPassword(32);
			$crypt = JUserHelper::getCryptedPassword($plain, $salt);
			$password = $crypt.':'.$salt;
						}
   // $password = md5($plain);
    return $password;
  }
?>
